package com.genexususa.eo.bing.data.results;

import com.genexususa.eo.bing.CampaignManagementServiceClasses.BatchError;
import com.genexususa.eo.bing.CampaignManagementServiceClasses.EditorialError;
import com.genexususa.eo.bing.data.GxItemException;

import javax.xml.bind.annotation.*;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "Bing_AdGroupsResults")
public class GxAdGroupsResults extends GxGeneralResults {
    @XmlElementWrapper(name = "AdGroupsResultCollection")
    @XmlElement(name = "AdGroupsResult")
    public GxAdGroupsResult[] adGroupsResultCollection;

    public GxAdGroupsResults() {
        super();
    }

    public GxAdGroupsResults(int resultQuantity) {
        super();
        this.adGroupsResultCollection = new GxAdGroupsResult[resultQuantity];
    }

    public void addResult(int index, GxAdGroupsResult adGroupsResult) {
        this.adGroupsResultCollection[index] = adGroupsResult;
    }

    public void addGxExceptionError(GxItemException error, int index) {
        this.adGroupsResultCollection[index].addGxExceptionError(error, index);
    }

    public void addBatchError(BatchError error) {
        this.adGroupsResultCollection[error.getIndex()].addBatchError(error);
    }

    public void addEditorialError(EditorialError error) {
        this.adGroupsResultCollection[error.getIndex()].addEditorialError(error);
    }

    public GxAdGroupsResult[] getAdGroupsResultCollection() {
        return adGroupsResultCollection;
    }

    public void setError() {
        this.hasError = true;
    }
}
